﻿@{
    Layout = null;
}
@model ElingOA6_Admin_DSJCJ.Model.HRPosition
<!DOCTYPE html>

<html>
@Html.Partial("LoadPanelPartial")
<head>
  @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
      <script src="@Url.Content("~/Scripts/regex.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)

    <script type="text/javascript">
        function OK() {
            lpModal.Show();
            var positionNo = tbPositionNo.GetText();
            var positionName = tbPositionName.GetText();
            var seq = tbSeq.GetText();

            if (null != positionNo) {
                positionNo = ASPxClientUtils.Trim(positionNo);
            }
            if (null != positionName) {
                positionName = ASPxClientUtils.Trim(positionName);
            }
            if (null != seq) {
                seq = ASPxClientUtils.Trim(seq);
            }

            if (pd(positionNo, positionName, seq)) {

                var prop = ddlPositionProp.GetValue();
                var propName = ddlPositionProp.GetText();
                var deptNo = $('#hidDeptNo').val();

                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/Dept/PositionSave',
                    data: { deptNo: deptNo, positionNo: positionNo, positionName: positionName, prop: prop, propName: propName, seq: seq, isAdd: '@ViewData["bl_position"]' },
                    success: function (result) {
                        lpModal.Hide();
                        if (result == "exists") {
                            tbPositionNo.SetErrorText("岗位编号已存在");
                            tbPositionNo.SetIsValid(false);
                        }
                        else if (result == "prop1") {
                            ddlPositionProp.SetErrorText("正级岗位只能有一个");
                            ddlPositionProp.SetIsValid(false);
                        }
                        else if (result == "ok") {
                            parent.positionOK();
                        }
                        else if (result == "no") {
                            alert("数据不存在");
                        }
                        else if (result == "error") {
                            alert("保存失败");
                        }
                        else if (result == "") {
                            alert("参数不正确");
                        }
                    }
                });

            } else {
                lpModal.Hide();
            }
        }

        function pd(positionNo, positionName, seq) {
            var bl = true;
            if (positionNo == null || ASPxClientUtils.Trim(positionNo) == "") {
                tbPositionNo.SetErrorText("请填写岗位编号");
                tbPositionNo.SetIsValid(false);
                bl = false;
            }

            if (positionName == null || ASPxClientUtils.Trim(positionName) == "") {
                tbPositionName.SetErrorText("请填写岗位名称");
                tbPositionName.SetIsValid(false);
                bl = false;
            }

            if (seq == null || ASPxClientUtils.Trim(seq) == "") {
                tbSeq.SetErrorText("请填写顺序");
                tbSeq.SetIsValid(false);
                bl = false;
            } else {
                if (!isNumeric(seq)) {
                    tbSeq.SetErrorText("顺序必须是整数!");
                    tbSeq.SetIsValid(false);
                    bl = false;
                }
            }

            return bl;
        }
    </script>

</head>
<body>
    <table class="tableFrom">
        <tr>
            <th>
                岗位编号:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbPositionNo";
                   settings.Width = 100;
                   settings.Text = Model.FPositionNo;
                   settings.Enabled = (bool)@ViewData["bl_position"];
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
                @Html.Hidden("hidDeptNo", Model.FDeptNo)
            </td>
        </tr>
        <tr>
            <th>
                岗位名称:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbPositionName";
                   settings.Width = 100;
                   settings.Text = Model.FPositionName;
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>
        <tr>
            <th>
                岗位性质:</th>
            <td>
                @Html.DevExpress().ComboBox(
            settings =>
            {
                settings.Name = "ddlPositionProp";
                settings.Properties.DropDownStyle = DropDownStyle.DropDownList;
                settings.Width = 100;
                settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                settings.Properties.ValidationSettings.EnableCustomValidation = true;
            }).BindList(new List<SelectListItem> { new SelectListItem { Text = "正级(主持工作)", Value = "1" }, new SelectListItem { Text = "副级", Value = "2" }, new SelectListItem { Text = "普通", Value = "9" } }).Bind(Model.FPositionProp).GetHtml()
            </td>
        </tr>
        <tr>
            <th>
                显示顺序:</th>
            <td>
                @Html.DevExpress().TextBox(settings =>
               {
                   settings.Name = "tbSeq";
                   settings.Width = 100;
                   settings.Text = Model.FSeq.ToString();
                   settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                   settings.Properties.ValidationSettings.EnableCustomValidation = true;
               }).GetHtml()
            </td>
        </tr>
       @* <tr>
            <td colspan="2">
                @Html.DevExpress().Button(settings =>
          {
              settings.Name = "btnOK";
              settings.Text = "确定";
              settings.ControlStyle.CssClass = "left";
              settings.ClientSideEvents.Click = "OK";
          }).GetHtml()
                @Html.DevExpress().Button(settings =>
          {
              settings.Name = "btnCancel";
              settings.Text = "取消";
              settings.CausesValidation = false;
              settings.ControlStyle.CssClass = "left";
              settings.ClientSideEvents.Click = "function(){parent.positonCancel();}";
          }).GetHtml()</td>
        </tr>*@
    </table>

    <script>
        lp.Hide();
    </script>

</body>
</html>
